package com.deyuanyun.pic.ae.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.settings.domain.base.Attachment;
import com.deyuanyun.pic.settings.support.biz.AttachmentUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 图片转换
 *
 * @author huanglw
 * @date 2016-11-15
 *
 * History: [修改人][时间][修改描述]
 */
public class ImgVO extends DefaultCommand<Attachment>{

    /**
     * 主键编号
     */
    private String id;

    /**
     * 备注
     */
    private String remark;

    /**
     * 文件名称
     */
    private String realName;

    /**
     * 文件保存路径
     */
    private String path;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @Override
    public void fromDomain(Attachment domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        this.id = domain.getId();
        this.remark = domain.getCreateRemark();
        this.realName = domain.getRealName();
        this.path = domain.getPath();
    }

    public static List<ImgVO> queryImgList(String businessId) {
        List<Attachment> attachmentList = AttachmentUtil.getAttachmentList(businessId);
        List<ImgVO> imgDtoList = new ArrayList<ImgVO>();
        for (Attachment attachment : attachmentList) {
            ImgVO imgDto = new ImgVO();
            imgDto.fromDomain(attachment);
            imgDtoList.add(imgDto);
        }
        return imgDtoList;
    }
}
